class User:
    def __init__(self, 用户名, 密码):
        self.用户名 = 用户名
        self.密码 = 密码
        self.balance = 0

    def A(self, amount):
        if amount > 0:
            self.balance += amount
            print(f"存款成功！当前余额: {self.balance}")
        else:
            print("存款金额必须大于0")

    def B(self, amount):
        if 0 < amount <= self.balance:
            self.balance -= amount
            print(f"取款成功！当前余额: {self.balance}")
        else:
            print("余额不足或取款金额无效")

    def C(self, recipient, amount):
        if 0 < amount <= self.balance:
            self.balance -= amount
            recipient.balance += amount
            print(f"转账成功！当前余额: {self.balance}")
        else:
            print("余额不足或转账金额无效")

    def check_balance(self):
        print(f"当前余额: {self.balance}")


class Bank:
    def __init__(self):
        self.users = {}
        self.current_user = None

    def register(self, 用户名, 密码):
        if 用户名 in self.users:
            print("用户名已存在！")
        else:
            self.users[用户名] = User(用户名, 密码)
            print("注册成功！")

    def login(self, 用户名, 密码):
        if 用户名 in self.users and self.users[用户名].密码 == 密码:
            self.current_user = self.users[用户名]
            print(f"欢迎回来，{用户名}！")
        else:
            print("用户名或密码错误！")

    def logout(self):
        if self.current_user:
            print(f"{self.current_user.用户名}已退出登录！")
            self.current_user = None
        else:
            print("当前没有用户登录！")


def main():
    bank = Bank()

    while True:
        if not bank.current_user:
            print("\n=== 银行系统 ===")
            print("1. 注册")
            print("2. 登录")
            print("3. 退出")
            choice = input("请选择操作: ")

            if choice == "1":
                用户名 = input("用户名: ")
                密码 = input("密码: ")
                bank.register(用户名, 密码)
            elif choice == "2":
                用户名 = input("用户名: ")
                密码 = input("密码: ")
                bank.login(用户名, 密码)
            elif choice == "3":
                print("感谢使用！")
                break
            else:
                print("无效选择！")
        else:
            print(f"\n=== {bank.current_user.用户名}的账户 ===")
            print("1. 存款")
            print("2. 取款")
            print("3. 查询余额")
            print("4. 转账")
            print("5. 退出登录")
            choice = input("请选择操作: ")

            if choice == "1":
                amount = float(input("存款金额: "))
                bank.current_user.A(amount)
            elif choice == "2":
                amount = float(input("取款金额: "))
                bank.current_user.B(amount)
            elif choice == "3":
                bank.current_user.check_balance()
            elif choice == "4":
                recipient = input("收款人用户名: ")
                if recipient in bank.users and recipient != bank.current_user.用户名:
                    amount = float(input("转账金额: "))
                    bank.current_user.C(bank.users[recipient], amount)
                else:
                    print("收款人不存在或不能给自己转账！")
            elif choice == "5":
                bank.logout()
            else:
                print("无效选择！")


if __name__ == "__main__":
    main()